package asteroids.statements;


import java.util.*;

import be.kuleuven.cs.som.annotate.Basic;

import asteroids.Ship;
import asteroids.types.Type;

public class SequenceStatement extends ComposedStatement {
	
	private List<Statement> statements;

	public SequenceStatement(int line, int column, List<Statement> statements) {
		super(line, column);
		this.statements = statements;
	}

	@Basic
	public List<Statement> getSubStatements() {
		return statements;
	}

	@Override
	public int getNbOfStatements() {
		return getSubStatements().size();
	}

	@Override
	public Statement getStatementAt(int index) throws IndexOutOfBoundsException {
		return getSubStatements().get(index-1);
	}

	@Override
	public void execute(Ship ship) {
		for(Statement statement: getSubStatements()){
			statement.execute(ship);
		}
	}

	@Override
	public List<String> getTypeCheckErrors(List<String> typeErrors, Map<String, Type> globalVariables) {
		for(Statement statement: getSubStatements()) {
			typeErrors = statement.getTypeCheckErrors(typeErrors, globalVariables);
		}
		return typeErrors;
	}
	
}
